<?php
/**
 *
 * @Author nikm $
 *
 * @Date 2013-08-19 $
 */

if(!defined('FROM_INDEX')) exit('Invalid request');

require ROOT_PATH.'mobiapi/modules/base.mod.php';
require ROOT_PATH."service/feed.service.php";

class ModuleObj extends BaseModule
{
	private $service;
	
	function __construct($request)
	{
		parent::__construct($request);
		
		$this->service = new FeedService();
		
		$this->excute();
	}
	
	function excute()
	{
		switch($this->act)
		{
			case 'count':
				$this->getFeedCount();
				break;
			case 'list':
				$this->getFeedList();
				break;
			case 'follow':
				$this->getFollowFeedList();
				break;
			default:
				$this->message('ACTION_NOT_EXISTS', STATUS_E);
		}
		
		$this->showResponse();
	}

	function getFeedCount()
	{
		$result = $this->service->get_feed_count($this->user['id']);
		
		if(!check_array($result)) $this->message('NO_RESULT', STATUS_F);
		
		$this->response['at_count'] = $result['at_count'];
		$this->response['follow_count'] = $result['follow_count'];
		$this->response['like_count'] = $result['like_count'];
		$this->response['comment_count'] = $result['comment_count'];
	}
	
	function getFeedList()
	{
		//$this->checkRequest('info');
		
		$this->request['uid'] = $this->user['id'];
		
		$result = $this->service->get_list_by_uid($this->request);
		
		if(!check_array($result)) $this->message('NO_RESULT', STATUS_F);
		
		$this->response['size'] = (string) count($result['list']);
		$this->response['list'] = $result['list'];
		$this->response['total_count'] = $result['total_count'];
	}
	
	function getFollowFeedList()
	{
		//$this->checkRequest('info');
		
		$this->request['uid'] = $this->user['id'];
		
		$result = $this->service->get_follow_list_by_uid($this->request);
		
		if(!check_array($result)) $this->message('NO_RESULT', STATUS_F);
		
		$this->response['size'] = (string) count($result['list']);
		$this->response['list'] = $result['list'];
		$this->response['total_count'] = $result['total_count'];
	}
}